package com.bthdung.studios.lesson12.framework;

import android.util.FloatMath;

public class Vector3
{
	public float x, y, z;

	public Vector3()
	{
		this(0, 0, 0);
	}

	public Vector3(float x, float y, float z)
	{
		this.x = x;
		this.y = y;
		this.z = z;
	}

	public static Vector3 sub(Vector3 v1, Vector3 v2)
	{
		return new Vector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
	}

	public static Vector3 cross(Vector3 vector1, Vector3 vector2)
	{
		Vector3 vector3 = new Vector3();
		vector3.x = (vector1.y * vector2.z) - (vector1.z * vector2.y);
		vector3.y = (vector1.z * vector2.x) - (vector1.x * vector2.z);
		vector3.z = (vector1.x * vector2.y) - (vector1.y * vector2.x);
		return vector3;
	}

	public void normalize()
	{
		float num2 = ((x * x) + (y * y)) + (z * z);
		float num = 1f / FloatMath.sqrt(num2);
		x *= num;
		y *= num;
		z *= num;
	}

	public void add(Vector3 v)
	{
		x += v.x;
		y += v.y;
		z += v.z;
	}

	@Override
	public String toString()
	{
		return "{ " + x + ", " + y + ", " + z + " }";
	}

	public static final Vector3 Zero = new Vector3(0, 0, 0);
	public static final Vector3 Up = new Vector3(0, 1, 0);
}